var userSelecter = {
	grid:null,
	show:function(onSelect){
		var boss = this;
		boss.dialog = sbl.dialog({
			url: burl + "/view/common/policeList.jsp",
			width: "630px",
			height: "500px",
			OnComplete:function(){
				
				boss.search();
				$("#searchBtn").bind("click",function(){
					boss.search();
				});
				
				$("#enter").bind("click", function(){
					var rows = boss.grid.getSelectRows();
					boss.dialog.remove();
					onSelect(rows);
				});
				
				sbl.ajax({
					url:burl+"/data/userDept.json",
					success:function(d){
						boss.userDeptdata = d;
						boss.DeptSelect();
					}
				});
			}
		});
	},
	search:function(){
		var boss = this;
		var data = sbl.getFormData("userSelecterForm");
		boss.grid = ManagerGrid.grid({
			url: burl + "/User/getUserEasyList.do",
			Data:data,
			columns: [{
				text: "账号", field: "username"
			}, {
				text: "用户名", field: "showname"
			}, {
				text: "单位", field: "deptname"
			}]
		}, "police_grid");
	},
	DeptSelect:function(){
		var boss = this;
		var pcs = boss.userDeptdata.pcs[1];
		$("#createrpcs").append("<option value=''>-请选择-</option>");
		for(var i =0;i<pcs.length;i++){
			var row = pcs[i];
			var option = $("<option value='"+row.id+"'>"+row.name+"</option>");
			$("#createrpcs").append(option);
		}
		
		$("#createrpcs").bind("change",function(){
			var pcs = $(this).val();
			var sq = boss.userDeptdata.sq[pcs];
			$("#createrjq").empty();
			$("#createrjq").append("<option value=''>-请选择-</option>");
			for(var i =0;i<sq.length;i++){
				var row = sq[i];
				var option = $("<option value='"+row.id+"'>"+row.name+"</option>");
				$("#createrjq").append(option);
			}
		});
	}
};